import request from "@/api/request";

export default {
    // 创建培训班级
    createTrainClass:(params)=>{
        return request({
            url:"/train/train-class/create",
            method:"post",
            data: params,
        })
    },
    // 获取培训班级
    getTrainClass:(params)=>{
        return request({
            url:"/train/train-class/page-all",
            method:"post",
            data: params,
        })
    },
    // 根据班级号获取邀请码
    getInviteCode:(params)=>{
        return request({
            url:`/train/train-class/get/inviteCode/${params.id}`,
            method:"get",
        })
    },
    // 根据班级号获取考生
    getTrainStudent:(params)=>{
        return request({
            url:"/train/train-class-user/page-all-user",
            method:"post",
            data:params
        })
    },
    // 根据班级号删除培训班级
    closeTrainClass:(params)=>{
        return request({
            url:`/train/train-class/close/train-class/${params.id}`,
            method:"get",
        })
    },
    // 根据班级号修改培训班级

    // 根据班级号和用户号添加一个学生
    addTrainStudent:(params)=>{
        return request({
            url:`/train/train-class-user/add-user`,
            method:"get",
            params:{trainClassId: params.trainClassId,userId: params.userId}
        })
    },
    // 根据学号和班级号删除一个学生
    deleteTrainStudent:(params)=>{
        return request({
            url:`/train/train-class/remove-user`,
            method:"get",
            params:{trainClassId: params.trainClassId,userId: params.userId}
        })
    },
    // 获取题库
    questionList:(param)=>{
        return request({
            url:'/problem/list',
            method:'post',
            data:param
        })
    },
    // 获取题库的类型
    getCategories:()=>{
        return request({
            url: '/category/list',
            method:'get',
        })
    },
    // 获取题库的某题目的详情
    questionDetail:(param)=>{
        return request({
            url:'/problem/detail',
            method:'post',
            data:param
        })
    },
    // 创建作业
    createHomework:(param)=>{
        return request({
            url:'/train/train-homework/create',
            method:'post',
            data:param
        })
    },
    // 将作业给班级
    assignHomework:(params)=>{
        return request({
            url:'/train/train-homework/assign-homework',
            method:'get',
            params:{trainClassId: params.trainClassId,homeworkId: params.homeworkId}
        })
    },
    // 根据班级号获取班级的作业
    getHomework:(params)=>{
        return request({
            url:'/train/train-homework/train-class/all-homework',
            method:'get',
            params:{pageNumber: params.pageNumber,pageSize: params.pageSize,trainClassId : params.trainClassId}
        })
    },
    //根据作业号获取题目
    getHomeworkProblem:(params)=>{
        return request({
            url:'/train/train-homework/homework-detail',
            method:'get',
            params:{homeworkId: params.homeworkId}
        })
    },
    //获取作业的题目
    getHomeworkProblemId:(params)=>{
        return request({
            url:'/train/train-homework/homework-problems',
            method:'get',
            params:{homeworkId: params.homeworkId}
        })
    },
    //删除作业
    deleteHomework:(params)=>{
        return request({
            url:'/train/train-homework/remove-homework',
            method:'get',
            params:{trainClassId: params.trainClassId , homeworkId: params.homeworkId}
        })
    },
    //关闭作业
    closeHomework:(params)=>{
        return request({
            url:'/train/train-homework/status-operate',
            method:'get',
            params:{id: params.id , status: 0}
        })
    },
    //更新作业时间
    updateHomework:(param)=>{
        return request({
            url:'/train/train-homework/update',
            method:'post',
            data:param
        })
    },
    //下载成绩要用blob解析
    downloadGrade:(params)=>{
        return request({
            url:'/train/train-class/report/download/user-report',
            method:'get',
            params:{homeworkId: params.homeworkId , classId: params.classId},
            responseType: 'blob'
        })
    },
    //获取作业的提交信息
    getHomeworkSubmission:(params)=>{
        return request({
            url:'/train/train-homework/class-homework/submit-detail',
            method:'get',
            params:{pageNumber: params.pageNumber , pageSize: params.pageSize, trainClassId: params.trainClassId, homeworkId: params.homeworkId}
        })
    },
    //根据学号获取班级
    getStudentClass:(params)=>{
        return request({
            url:'train/train-class-user/user',
            method:'get',
            params:{pageNumber: params.pageNumber , pageSize: params.pageSize, userId: params.userId},

        })
    },
    //根据id获取班级的所有作业
    getAllClassHomework:(params)=>{
        return request({
            url:'/train/train-homework/train-class/all-homework-no-page',
            method:'get',
            params:{classId: params.classId},
        })
    },
    //修改培训班级信息
    changeTrainClassName:(params)=>{
        return request({
            url:'/train/train-class/update',
            method:'post',
            data: params
        })
    },
    //查询某一个用户某个班级的作业记录
    getTrainClassRecord:(params)=>{
        return request({
            url:'/train/train-class-user/user/class-homework',
            method:'get',
            params:{pageNumber: params.pageNumber , pageSize: params.pageSize, trainClassId: params.trainClassId ,userId :params.userId},
        })
    },
    // 评分手动
    scoreHomework:(params)=>{
        return request({
            url:'/train/train-homework/class-homework/chang-score',
            method:'get',
            params:{userId: params.userId , submitId: params.submitId, score: params.score},
        })
    },
    // 获取最新的评测记录列表
    getNowSub:(params)=>{
        return request({
            url:'/submission/getLatestSubmissions',
            method:'post',
            data: params
        })
    },
    // 下载查重报告
    downloadChachong:(params)=>{
        return request({
            url:'/train/train-class/report/downloadRepCheckReport',
            method:'get',
            params:{classId: params.classId, homeworkId: params.homeworkId},
            responseType: 'blob'
        })
    },

}
